Optimal. Leaf size=290 \[ -\frac {2 a^4 \left (A \left (64+60 m+19 m^2+2 m^3\right )-i B \left (67+60 m+19 m^2+2 m^3\right )\right ) \tan ^{1+m}(c+d x)}{d (1+m) (2+m) (3+m) (4+m)}+\frac {8 a^4 (A-i B) \, _2F_1(1,1+m;2+m;i \tan (c+d x)) \tan ^{1+m}(c+d x)}{d (1+m)}+\frac {i a B \tan ^{1+m}(c+d x) (a+i a \tan (c+d x))^3}{d (4+m)}-\frac {(A (4+m)-i B (7+m)) \tan ^{1+m}(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )^2}{d (3+m) (4+m)}-\frac {2 \left (A (4+m)^2-i B \left (19+8 m+m^2\right )\right ) \tan ^{1+m}(c+d x) \left (a^4+i a^4 \tan (c+d x)\right )}{d (2+m) (3+m) (4+m)} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.75, antiderivative size = 290, normalized size of antiderivative = 1.00, number of steps
used = 7, number of rules used = 5, integrand size = 34, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.147, Rules used = {3675, 3673,
3618, 12, 66} \begin {gather*} \frac {8 a^4 (A-i B) \tan ^{m+1}(c+d x) \, _2F_1(1,m+1;m+2;i \tan (c+d x))}{d (m+1)}-\frac {2 \left (A (m+4)^2-i B \left (m^2+8 m+19\right )\right ) \left (a^4+i a^4 \tan (c+d x)\right ) \tan ^{m+1}(c+d x)}{d (m+2) (m+3) (m+4)}-\frac {2 a^4 \left (A \left (2 m^3+19 m^2+60 m+64\right )-i B \left (2 m^3+19 m^2+60 m+67\right )\right ) \tan ^{m+1}(c+d x)}{d (m+1) (m+2) (m+3) (m+4)}-\frac {(A (m+4)-i B (m+7)) \left (a^2+i a^2 \tan (c+d x)\right )^2 \tan ^{m+1}(c+d x)}{d (m+3) (m+4)}+\frac {i a B (a+i a \tan (c+d x))^3 \tan ^{m+1}(c+d x)}{d (m+4)} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 12
Rule 66
Rule 3618
Rule 3673
Rule 3675
Rubi steps
\begin {align*} \int \tan ^m(c+d x) (a+i a \tan (c+d x))^4 (A+B \tan (c+d x)) \, dx &=\frac {i a B \tan ^{1+m}(c+d x) (a+i a \tan (c+d x))^3}{d (4+m)}+\frac {\int \tan ^m(c+d x) (a+i a \tan (c+d x))^3 (-a (i B (1+m)-A (4+m))+a (i A (4+m)+B (7+m)) \tan (c+d x)) \, dx}{4+m}\\ &=\frac {i a B \tan ^{1+m}(c+d x) (a+i a \tan (c+d x))^3}{d (4+m)}-\frac {(A (4+m)-i B (7+m)) \tan ^{1+m}(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )^2}{d (3+m) (4+m)}+\frac {\int \tan ^m(c+d x) (a+i a \tan (c+d x))^2 \left (-2 a^2 \left (i B \left (5+6 m+m^2\right )-A \left (8+6 m+m^2\right )\right )+2 a^2 \left (i A (4+m)^2+B \left (19+8 m+m^2\right )\right ) \tan (c+d x)\right ) \, dx}{12+7 m+m^2}\\ &=\frac {i a B \tan ^{1+m}(c+d x) (a+i a \tan (c+d x))^3}{d (4+m)}-\frac {(A (4+m)-i B (7+m)) \tan ^{1+m}(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )^2}{d (3+m) (4+m)}-\frac {2 \left (A (4+m)^2-i B \left (19+8 m+m^2\right )\right ) \tan ^{1+m}(c+d x) \left (a^4+i a^4 \tan (c+d x)\right )}{d (2+m) \left (12+7 m+m^2\right )}+\frac {\int \tan ^m(c+d x) (a+i a \tan (c+d x)) \left (-2 a^3 \left (i B \left (29+44 m+17 m^2+2 m^3\right )-A \left (32+44 m+17 m^2+2 m^3\right )\right )+2 a^3 \left (i A \left (64+60 m+19 m^2+2 m^3\right )+B \left (67+60 m+19 m^2+2 m^3\right )\right ) \tan (c+d x)\right ) \, dx}{24+26 m+9 m^2+m^3}\\ &=-\frac {2 a^4 \left (A \left (64+60 m+19 m^2+2 m^3\right )-i B \left (67+60 m+19 m^2+2 m^3\right )\right ) \tan ^{1+m}(c+d x)}{d (1+m) \left (24+26 m+9 m^2+m^3\right )}+\frac {i a B \tan ^{1+m}(c+d x) (a+i a \tan (c+d x))^3}{d (4+m)}-\frac {(A (4+m)-i B (7+m)) \tan ^{1+m}(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )^2}{d (3+m) (4+m)}-\frac {2 \left (A (4+m)^2-i B \left (19+8 m+m^2\right )\right ) \tan ^{1+m}(c+d x) \left (a^4+i a^4 \tan (c+d x)\right )}{d (2+m) \left (12+7 m+m^2\right )}+\frac {\int \tan ^m(c+d x) \left (8 a^4 (A-i B) (2+m) (3+m) (4+m)+8 a^4 (i A+B) (2+m) (3+m) (4+m) \tan (c+d x)\right ) \, dx}{24+26 m+9 m^2+m^3}\\ &=-\frac {2 a^4 \left (A \left (64+60 m+19 m^2+2 m^3\right )-i B \left (67+60 m+19 m^2+2 m^3\right )\right ) \tan ^{1+m}(c+d x)}{d (1+m) \left (24+26 m+9 m^2+m^3\right )}+\frac {i a B \tan ^{1+m}(c+d x) (a+i a \tan (c+d x))^3}{d (4+m)}-\frac {(A (4+m)-i B (7+m)) \tan ^{1+m}(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )^2}{d (3+m) (4+m)}-\frac {2 \left (A (4+m)^2-i B \left (19+8 m+m^2\right )\right ) \tan ^{1+m}(c+d x) \left (a^4+i a^4 \tan (c+d x)\right )}{d (2+m) \left (12+7 m+m^2\right )}+\frac {\left (64 i a^8 (A-i B)^2 (2+m) (3+m) (4+m)\right ) \text {Subst}\left (\int \frac {8^{-m} \left (\frac {x}{a^4 (i A+B) (2+m) (3+m) (4+m)}\right )^m}{64 a^8 (i A+B)^2 (2+m)^2 (3+m)^2 (4+m)^2+8 a^4 (A-i B) (2+m) (3+m) (4+m) x} \, dx,x,8 a^4 (i A+B) (2+m) (3+m) (4+m) \tan (c+d x)\right )}{d}\\ &=-\frac {2 a^4 \left (A \left (64+60 m+19 m^2+2 m^3\right )-i B \left (67+60 m+19 m^2+2 m^3\right )\right ) \tan ^{1+m}(c+d x)}{d (1+m) \left (24+26 m+9 m^2+m^3\right )}+\frac {i a B \tan ^{1+m}(c+d x) (a+i a \tan (c+d x))^3}{d (4+m)}-\frac {(A (4+m)-i B (7+m)) \tan ^{1+m}(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )^2}{d (3+m) (4+m)}-\frac {2 \left (A (4+m)^2-i B \left (19+8 m+m^2\right )\right ) \tan ^{1+m}(c+d x) \left (a^4+i a^4 \tan (c+d x)\right )}{d (2+m) \left (12+7 m+m^2\right )}+\frac {\left (i 8^{2-m} a^8 (A-i B)^2 (2+m) (3+m) (4+m)\right ) \text {Subst}\left (\int \frac {\left (\frac {x}{a^4 (i A+B) (2+m) (3+m) (4+m)}\right )^m}{64 a^8 (i A+B)^2 (2+m)^2 (3+m)^2 (4+m)^2+8 a^4 (A-i B) (2+m) (3+m) (4+m) x} \, dx,x,8 a^4 (i A+B) (2+m) (3+m) (4+m) \tan (c+d x)\right )}{d}\\ &=-\frac {2 a^4 \left (A \left (64+60 m+19 m^2+2 m^3\right )-i B \left (67+60 m+19 m^2+2 m^3\right )\right ) \tan ^{1+m}(c+d x)}{d (1+m) \left (24+26 m+9 m^2+m^3\right )}+\frac {8 a^4 (A-i B) \, _2F_1(1,1+m;2+m;i \tan (c+d x)) \tan ^{1+m}(c+d x)}{d (1+m)}+\frac {i a B \tan ^{1+m}(c+d x) (a+i a \tan (c+d x))^3}{d (4+m)}-\frac {(A (4+m)-i B (7+m)) \tan ^{1+m}(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )^2}{d (3+m) (4+m)}-\frac {2 \left (A (4+m)^2-i B \left (19+8 m+m^2\right )\right ) \tan ^{1+m}(c+d x) \left (a^4+i a^4 \tan (c+d x)\right )}{d (2+m) \left (12+7 m+m^2\right )}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Both result and optimal contain complex but leaf count is larger than twice
the leaf count of optimal. \(1805\) vs. \(2(290)=580\).
time = 9.97, size = 1805, normalized size = 6.22 \begin {gather*} \frac {2^{3-m} (i A+B) e^{-2 i c} \left (-\frac {i \left (-1+e^{2 i (c+d x)}\right )}{1+e^{2 i (c+d x)}}\right )^m \cos ^5(c+d x) \left (2^m \, _2F_1\left (1,m;1+m;-\frac {-1+e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )-\left (1+e^{2 i (c+d x)}\right )^m \, _2F_1\left (m,m;1+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )\right ) (a+i a \tan (c+d x))^4 (A+B \tan (c+d x))}{d \left (1+e^{2 i c}\right ) m (\cos (d x)+i \sin (d x))^4 (A \cos (c+d x)+B \sin (c+d x))}-\frac {8 i (A-i B) e^{-4 i c} \left (-1+e^{2 i (c+d x)}\right )^m \left (-\frac {i \left (-1+e^{2 i (c+d x)}\right )}{1+e^{2 i (c+d x)}}\right )^m \left (\frac {-1+e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )^{-m} \cos ^5(c+d x) \left (-\frac {\left (1+e^{2 i (c+d x)}\right )^{-m} \, _2F_1\left (1,m;1+m;\frac {1-e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )}{m}-\frac {\left (1+e^{2 i c}\right ) \left (-1+e^{2 i (c+d x)}\right ) \left (1+e^{2 i (c+d x)}\right )^{-1-m} \, _2F_1\left (1,1+m;2+m;\frac {1-e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )}{1+m}+\frac {2^{-m} \, _2F_1\left (m,m;1+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )}{m}\right ) (a+i a \tan (c+d x))^4 (A+B \tan (c+d x))}{d \left (1+e^{2 i c}\right ) (\cos (d x)+i \sin (d x))^4 (A \cos (c+d x)+B \sin (c+d x))}+\frac {\cos ^5(c+d x) \left (\frac {(A-2 i B) \sec ^2(c+d x) (-4 i \cos (4 c)-4 \sin (4 c))}{2+m}+\frac {(A-2 i B) (-3-2 m+\cos (2 c)) \sec ^2(c) (-2 i \cos (4 c)-2 \sin (4 c))}{(1+m) (2+m)}+\frac {(i A \cos (c-d x)+2 B \cos (c-d x)-i A \cos (c+d x)-2 B \cos (c+d x)) \sec ^2(c) \sec (c+d x) (2 \cos (4 c)-2 i \sin (4 c))}{1+m}\right ) \tan ^m(c+d x) (a+i a \tan (c+d x))^4 (A+B \tan (c+d x))}{d (\cos (d x)+i \sin (d x))^4 (A \cos (c+d x)+B \sin (c+d x))}+\frac {\cos ^5(c+d x) \left (\frac {\left (-8 B-9 B m-2 B m^2+8 B \cos (2 c)+3 B m \cos (2 c)\right ) \sec ^2(c) \sec ^2(c+d x) \left (\frac {1}{2} \cos (4 c)-\frac {1}{2} i \sin (4 c)\right )}{(2+m) \left (12+7 m+m^2\right )}+\frac {(-B \cos (c-d x)+B \cos (c+d x)) \sec ^2(c) \sec ^3(c+d x) \left (\frac {1}{2} \cos (4 c)-\frac {1}{2} i \sin (4 c)\right )}{3+m}+\frac {(-B \cos (c-d x)+B \cos (c+d x)) \sec ^2(c) \sec (c+d x) (\cos (4 c)-i \sin (4 c))}{(1+m) (3+m)}+\frac {\left (-11-10 m-2 m^2+5 \cos (2 c)+2 m \cos (2 c)\right ) \sec ^2(c) (B \cos (4 c)-i B \sin (4 c))}{(1+m) (2+m) (3+m) (4+m)}+\frac {\sec ^4(c+d x) (B \cos (4 c)-i B \sin (4 c))}{4+m}\right ) \tan ^m(c+d x) (a+i a \tan (c+d x))^4 (A+B \tan (c+d x))}{d (\cos (d x)+i \sin (d x))^4 (A \cos (c+d x)+B \sin (c+d x))}+\frac {\cos ^5(c+d x) \left (\frac {\sec ^2(c) \sec ^2(c+d x) (B-B \cos (2 c)+A \sin (2 c)-4 i B \sin (2 c)) \left (\frac {1}{2} \cos (4 c)-\frac {1}{2} i \sin (4 c)\right )}{3+m}+\frac {\sec ^2(c) \sec ^3(c+d x) \left (\frac {1}{2} \cos (4 c)-\frac {1}{2} i \sin (4 c)\right ) (B \cos (c-d x)-B \cos (c+d x)-A \sin (c-d x)+4 i B \sin (c-d x)+A \sin (c+d x)-4 i B \sin (c+d x))}{3+m}+\frac {\sec ^2(c) \sec (c+d x) (\cos (4 c)-i \sin (4 c)) (B \cos (c-d x)-B \cos (c+d x)-A \sin (c-d x)+4 i B \sin (c-d x)+A \sin (c+d x)-4 i B \sin (c+d x))}{(1+m) (3+m)}+\frac {\sec (c) (A \cos (c)-4 i B \cos (c)+B \sin (c)) (2 \cos (4 c)-2 i \sin (4 c)) \tan (c)}{(1+m) (3+m)}\right ) \tan ^m(c+d x) (a+i a \tan (c+d x))^4 (A+B \tan (c+d x))}{d (\cos (d x)+i \sin (d x))^4 (A \cos (c+d x)+B \sin (c+d x))}+\frac {\cos ^5(c+d x) \left (\frac {\sec ^2(c) \sec (c+d x) (2 \cos (4 c)-2 i \sin (4 c)) (-i A \cos (c-d x)-2 B \cos (c-d x)+i A \cos (c+d x)+2 B \cos (c+d x)+2 A \sin (c-d x)-3 i B \sin (c-d x)-2 A \sin (c+d x)+3 i B \sin (c+d x))}{1+m}+\frac {\sec (c) (2 A \cos (c)-3 i B \cos (c)+i A \sin (c)+2 B \sin (c)) (-4 \cos (4 c)+4 i \sin (4 c)) \tan (c)}{1+m}\right ) \tan ^m(c+d x) (a+i a \tan (c+d x))^4 (A+B \tan (c+d x))}{d (\cos (d x)+i \sin (d x))^4 (A \cos (c+d x)+B \sin (c+d x))} \end {gather*}
Warning: Unable to verify antiderivative.
[In]
[Out]
________________________________________________________________________________________
Maple [F]
time = 0.52, size = 0, normalized size = 0.00 \[\int \left (\tan ^{m}\left (d x +c \right )\right ) \left (a +i a \tan \left (d x +c \right )\right )^{4} \left (A +B \tan \left (d x +c \right )\right )\, dx\]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Failed to integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} a^{4} \left (\int A \tan ^{m}{\left (c + d x \right )}\, dx + \int \left (- 6 A \tan ^{2}{\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\right )\, dx + \int A \tan ^{4}{\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\, dx + \int B \tan {\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\, dx + \int \left (- 6 B \tan ^{3}{\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\right )\, dx + \int B \tan ^{5}{\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\, dx + \int 4 i A \tan {\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\, dx + \int \left (- 4 i A \tan ^{3}{\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\right )\, dx + \int 4 i B \tan ^{2}{\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\, dx + \int \left (- 4 i B \tan ^{4}{\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\right )\, dx\right ) \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [F]
time = 0.00, size = -1, normalized size = -0.00 \begin {gather*} \int {\mathrm {tan}\left (c+d\,x\right )}^m\,\left (A+B\,\mathrm {tan}\left (c+d\,x\right )\right )\,{\left (a+a\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}\right )}^4 \,d x \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________